<html>
<head><meta charset="utf-8"><title>from slice to List · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html">from slice to List</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="177848356"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177848356" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177848356">(Oct 10 2019 at 20:04)</a>:</h4>
<p>is there a way to go from <code>&amp;[T]</code> to <code>&amp;List&lt;T&gt;</code> ?</p>



<a name="177848815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177848815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177848815">(Oct 10 2019 at 20:09)</a>:</h4>
<p>I think you'd need to intern it?</p>



<a name="177848818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177848818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177848818">(Oct 10 2019 at 20:09)</a>:</h4>
<p>depends on the T, I suspect</p>



<a name="177848888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177848888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177848888">(Oct 10 2019 at 20:10)</a>:</h4>
<p>yeah, you need to intern</p>



<a name="177849063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177849063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177849063">(Oct 10 2019 at 20:12)</a>:</h4>
<p>yeah that was my guess</p>



<a name="177849080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177849080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177849080">(Oct 10 2019 at 20:12)</a>:</h4>
<p>shouldn't one be able without that?</p>



<a name="177849152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177849152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177849152">(Oct 10 2019 at 20:13)</a>:</h4>
<p>List is a wrapper around a slice so I'd like to move the slice inside the List and return a pointer to that just created wrapper</p>



<a name="177849505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177849505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177849505">(Oct 10 2019 at 20:16)</a>:</h4>
<p>List specifically is "I am interned"</p>



<a name="177849525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177849525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177849525">(Oct 10 2019 at 20:17)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/9c588c1e2391c20c156814f7ae118f62e96a3976/src/librustc/ty/mod.rs#L608-L613" target="_blank" title="https://github.com/rust-lang/rust/blob/9c588c1e2391c20c156814f7ae118f62e96a3976/src/librustc/ty/mod.rs#L608-L613">https://github.com/rust-lang/rust/blob/9c588c1e2391c20c156814f7ae118f62e96a3976/src/librustc/ty/mod.rs#L608-L613</a></p>



<a name="177849533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177849533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177849533">(Oct 10 2019 at 20:17)</a>:</h4>
<p>at least per the doc comment on it</p>



<a name="177850248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177850248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177850248">(Oct 10 2019 at 20:25)</a>:</h4>
<p>yeah maybe I can talk about the specific case I'm hitting ...</p>



<a name="177850267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177850267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177850267">(Oct 10 2019 at 20:25)</a>:</h4>
<p>I'm trying to use it inside a Cow</p>



<a name="177850295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177850295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177850295">(Oct 10 2019 at 20:25)</a>:</h4>
<p>I want to create copies on write but copies may not happen and I want to do nothing</p>



<a name="177850511"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177850511" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177850511">(Oct 10 2019 at 20:27)</a>:</h4>
<p>the problem is that I can't wrap a List in a Cow so I end converting it to a slice at some point but if nothing happens I want the List back out of that slice</p>



<a name="177850577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177850577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177850577">(Oct 10 2019 at 20:28)</a>:</h4>
<p>I have the original List still somewhere but was wondering if this could be done</p>



<a name="177853708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177853708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177853708">(Oct 10 2019 at 21:06)</a>:</h4>
<p>I think what you want is basically not possible</p>



<a name="177853735"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177853735" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177853735">(Oct 10 2019 at 21:07)</a>:</h4>
<p>maybe a custom cow that re-interns on write or something</p>



<a name="177856558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177856558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177856558">(Oct 10 2019 at 21:42)</a>:</h4>
<p>the thing is I want that conversion when a write didn't occur, if I write occurs I needto reintern for sure</p>



<a name="177856568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177856568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177856568">(Oct 10 2019 at 21:42)</a>:</h4>
<p>I meant, I have solved this in a different and better way</p>



<a name="177856585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177856585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177856585">(Oct 10 2019 at 21:42)</a>:</h4>
<p>but still I was wondering in general if was possible to go from <code>&amp;[T]</code> to <code>&amp;List&lt;T&gt;</code></p>



<a name="177857128"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177857128" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177857128">(Oct 10 2019 at 21:51)</a>:</h4>
<p>sure, by interning for some T</p>



<a name="177857134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/from%20slice%20to%20List/near/177857134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/from.20slice.20to.20List.html#177857134">(Oct 10 2019 at 21:51)</a>:</h4>
<p>but not otherwise</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>